Skip to content

Conversation

@radik878
Copy link

Adjust hex encoding buffers to allocate enough capacity for the full 64-character hexadecimal representation of a Word. Previously we used 32/Word::SERIALIZED_SIZE (bytes) as the Vec capacity, which was half of the required number of characters and caused unnecessary reallocations; now both word.rs and digest.rs use Word::SERIALIZED_SIZE * 2 for consistent and efficient hex formatting.

Comment on lines 39 to 44
let mut data: Vec<char> = Vec::with_capacity(Word::SERIALIZED_SIZE * 2);
data.extend(format!("{:016x}", self.d0).chars());
data.extend(format!("{:016x}", self.d1).chars());
data.extend(format!("{:016x}", self.d2).chars());
data.extend(format!("{:016x}", self.d3).chars());
data.into_iter().collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also get rid of the format!() allocations by creating a String and write!()ing once

@igamigo
Copy link
Collaborator

igamigo commented Jan 17, 2026

Closing this as stale, @radik878 please feel free to reopen if you want to continue working onthis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants